# 开发时间: 2024/1/21 17:06
from timeit import timeit

import numpy as np


def python_sum(n):
    """
    python 实现数组的加法
    n 为数组的长度
    """
    a = [i**2 for i in range(n)]
    b = [i**3 for i in range(n)]
    c = []
    for i in range(n):
        c.append(a[i] + b[i])
    return c


print(python_sum(10))

def numpy_sum(n):
    """
    Numpy 实现数组的加法
    n 为数组的长度
    """
    a = np.arange(n) ** 2
    b = np.arange(n) ** 3
    return a + b


print(numpy_sum(10))

arr = np.array([
    [2,3],
    [5,4],
    [9,6],
    [4,7],
    [8,1],
    [7,2]
])

print(np.var(arr, axis=0))
